package com.zyy.client;

import com.zyy.service.IHelloService;
import com.zyy.pojo.User;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;

/**
 * @author zyy
 * @date 2021/1/27 上午11:46
 * @description
 */
public class RMIClient {
    public static void main(String[] args) throws RemoteException, NotBoundException, MalformedURLException {
        //1.从注册表中获取远程对象，强转
        IHelloService helloService = (IHelloService) Naming.lookup("//127.0.0.1:8888/rmiserver");

        //2.准备参数
        User user = new User("zhangsan",18);

        //3.调用远程方法SayHello
        String message = helloService.sayHello(user);
        System.out.println(message);
    }
}
